package project.bank.contoller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

import project.bank.views.IObserver;
import project.bank.views.JDialog_Entry;

public class ControllerEntry implements ActionListener, IController  {
	private JDialog_Entry dialog;
	private IObserver view;

	public ControllerEntry(IObserver view) {
		this.view = view;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		JButton btn = (JButton) e.getSource();
		if(btn.getActionCommand().equals("OK")) {
			// add data to model here
			view.update(null);

		}
		dialog.dispose();
	}

	public void setDialog(JDialog_Entry dialog) {
		this.dialog = dialog;
	}

	public void setAccount(String no) {
		dialog.setAccountNo(no);
	}

	@Override
	public void showDialog() {
		dialog.clearText();
		dialog.show();
	}
}
